﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC.Music.Data;
using MVC.Music.Data.Models;
using PetaPoco;
using PetaPoco.Profiling;
using MVC.Music.Data.Repositories;
namespace MVC.MusicCMS.Web.Controllers
{
    public class BaseController : Controller
    {
        protected DatabaseWithProfiling _database;
        protected TrackRepository _trackRepository;

        protected BitrateRepository _bitrateRepository;
        protected override RedirectToRouteResult RedirectToAction(string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues)
        {
            //DatabaseWithProfiling.( TempData);
            return base.RedirectToAction(actionName, controllerName, routeValues);
        }

        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            _database = new DatabaseWithProfiling("strcnn");
            _trackRepository = new TrackRepository(_database);
            _bitrateRepository = new BitrateRepository(_database);
            HttpContext.Items[DatabaseWithProfiling.PetaKey] = TempData[DatabaseWithProfiling.PetaKey];
        }
        protected void ThisControllerLivesInWebsiteSection(string sectionName)
        {
            ViewData["WebsiteSectionName"] = sectionName;
        }

    }
}
